Will [WithEvents = Nothing] RemoveHandlers in the derived class?
Posted
by serhio
on Stack Overflow
See other posts from Stack Overflow
or by serhio
Published on 2010-03-19T11:06:19Z
Indexed on
2010/03/19
11:11 UTC
Read the original article
Hit count: 110
I use to set WithEvents variables to Nothing in Destuctor, because this will "Remove" all the Handlers associated with Handles keyword. Will this have the same effect for derivated classes?
Class A
Protected WithEvents _Foo as Button
Private Sub _Foo_Click Handles _Foo.Click
' ... some Click action '
End Sub
Public Sub Dispose(disposing as Boolean)
If disposing then _Foo = Nothing ' remove handler _Foo_Click '
End Sub
End Class
Class B
Inherits A
Private Sub _Foo_Move Handles _Foo.Move
' ... some Move action '
End Sub
' ????? will or NOT remove OR handler _Foo_Move the base Dispose??'
Public Overrides Sub Dispose(disposing as Boolean)
'If disposing then _Foo = Nothing '
MyBase.Dispose(disposing)
End Sub
End Class
© Stack Overflow or respective owner